
package com.joolun.cloud.mall.api.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joolun.cloud.common.core.util.R;
import com.joolun.cloud.mall.api.annotation.ApiLogin;
import com.joolun.cloud.mall.api.service.DistributionConfigService;
import com.joolun.cloud.mall.api.service.DistributionUserService;
import com.joolun.cloud.mall.api.util.ThirdSessionHolder;
import com.joolun.cloud.mall.common.entity.DistributionUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 分销员
 *
 * @author www.joolun.com
 * @date 2021-04-25 17:40:35
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/distributionuser")
@Api(value = "distributionuser", tags = "分销员API")
public class DistributionUserController {

    private final DistributionUserService distributionUserService;

	/**
     * 分销员分页列表
     * @param page 分页对象
     * @param distributionUser 分销员
     * @return
     */
    @ApiOperation(value = "分销员分页列表")
    @GetMapping("/page")
	@ApiLogin
    public R getPage(Page page, DistributionUser distributionUser) {
        return R.ok(distributionUserService.page1(page, distributionUser));
    }

    /**
     * 当前用户分销员查询
     * @return R
     */
    @ApiOperation(value = "当前用户分销员查询")
    @GetMapping
	@ApiLogin
    public R getById() {
        return R.ok(distributionUserService.getDistributionUser(ThirdSessionHolder.getUserId()));
    }

}
